package o;

import android.content.ComponentCallbacks2;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import com.bumptech.glide.Glide;
import java.io.File;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import o.yf.c;

public class rp implements ComponentCallbacks2, ym {
    private static final zp ʽ = ((zp) ((zp) zp.ˎ(tf.ˏ).ॱ(rl.LOW)).ॱ(true));
    private static final zp ˊ = ((zp) zp.ˊ(xt.class).ˋॱ());
    private static final zp ˏ = ((zp) zp.ˊ(Bitmap.class).ˋॱ());
    private final Runnable ʻ;
    @GuardedBy("this")
    private final yw ʼ;
    private boolean ˊॱ;
    protected final Glide ˋ;
    private final Handler ˋॱ;
    protected final Context ˎ;
    private final CopyOnWriteArrayList<zn<Object>> ˏॱ;
    @GuardedBy("this")
    private zp ͺ;
    final yo ॱ;
    private final yf ॱˊ;
    @GuardedBy("this")
    private final yq ॱॱ;
    @GuardedBy("this")
    private final yr ᐝ;

    class e implements c {
        final /* synthetic */ rp ˋ;
        @GuardedBy("RequestManager.this")
        private final yq ˎ;

        e(rp rpVar, @NonNull yq yqVar) {
            this.ˋ = rpVar;
            this.ˎ = yqVar;
        }

        public void ˏ(boolean z) {
            if (z) {
                synchronized (this.ˋ) {
                    this.ˎ.ॱ();
                }
            }
        }
    }

    public rp(@NonNull Glide glide, @NonNull yo yoVar, @NonNull yr yrVar, @NonNull Context context) {
        this(glide, yoVar, yrVar, new yq(), glide.ˊ(), context);
    }

    rp(Glide glide, yo yoVar, yr yrVar, yq yqVar, yi yiVar, Context context) {
        this.ʼ = new yw();
        this.ʻ = new Runnable(this) {
            final /* synthetic */ rp ॱ;

            {
                this.ॱ = r1;
            }

            public void run() {
                this.ॱ.ॱ.ॱ(this.ॱ);
            }
        };
        this.ˋॱ = new Handler(Looper.getMainLooper());
        this.ˋ = glide;
        this.ॱ = yoVar;
        this.ᐝ = yrVar;
        this.ॱॱ = yqVar;
        this.ˎ = context;
        this.ॱˊ = yiVar.ˊ(context.getApplicationContext(), new e(this, yqVar));
        if (aau.ˋ()) {
            this.ˋॱ.post(this.ʻ);
        } else {
            yoVar.ॱ(this);
        }
        yoVar.ॱ(this.ॱˊ);
        this.ˏॱ = new CopyOnWriteArrayList(glide.ॱ().ˎ());
        ˏ(glide.ॱ().ˋ());
        glide.ˎ(this);
    }

    protected synchronized void ˏ(@NonNull zp zpVar) {
        this.ͺ = (zp) ((zp) zpVar.ˎ()).ˏॱ();
    }

    public synchronized void ˏ() {
        this.ॱॱ.ˎ();
    }

    public synchronized void ˋ() {
        this.ॱॱ.ˏ();
    }

    public synchronized void ˎ() {
        ˋ();
        for (rp ˋ : this.ᐝ.ˋ()) {
            ˋ.ˋ();
        }
    }

    public synchronized void ˊ() {
        this.ॱॱ.ˋ();
    }

    public synchronized void onStart() {
        ˊ();
        this.ʼ.onStart();
    }

    public synchronized void onStop() {
        ˏ();
        this.ʼ.onStop();
    }

    public synchronized void onDestroy() {
        this.ʼ.onDestroy();
        for (zz ˎ : this.ʼ.ˎ()) {
            ˎ(ˎ);
        }
        this.ʼ.ˋ();
        this.ॱॱ.ˊ();
        this.ॱ.ˎ(this);
        this.ॱ.ˎ(this.ॱˊ);
        this.ˋॱ.removeCallbacks(this.ʻ);
        this.ˋ.ˋ(this);
    }

    @CheckResult
    @NonNull
    public ro<Bitmap> ॱ() {
        return ˊ(Bitmap.class).ॱ(ˏ);
    }

    @CheckResult
    @NonNull
    public ro<xt> ʼ() {
        return ˊ(xt.class).ॱ(ˊ);
    }

    @CheckResult
    @NonNull
    public ro<Drawable> ᐝ() {
        return ˊ(Drawable.class);
    }

    @CheckResult
    @NonNull
    public ro<Drawable> ˏ(@Nullable String str) {
        return ᐝ().ˎ(str);
    }

    @CheckResult
    @NonNull
    public ro<Drawable> ॱ(@Nullable File file) {
        return ᐝ().ˊ(file);
    }

    @CheckResult
    @NonNull
    public ro<Drawable> ॱ(@RawRes @DrawableRes @Nullable Integer num) {
        return ᐝ().ˋ(num);
    }

    @CheckResult
    @NonNull
    public <ResourceType> ro<ResourceType> ˊ(@NonNull Class<ResourceType> cls) {
        return new ro(this.ˋ, this, cls, this.ˎ);
    }

    public void ˎ(@Nullable zz<?> zzVar) {
        if (zzVar != null) {
            ˏ((zz) zzVar);
        }
    }

    private void ˏ(@NonNull zz<?> zzVar) {
        boolean ˊ = ˊ((zz) zzVar);
        zm request = zzVar.getRequest();
        if (!ˊ && !this.ˋ.ॱ((zz) zzVar) && request != null) {
            zzVar.setRequest(null);
            request.ॱ();
        }
    }

    public synchronized boolean ˊ(@NonNull zz<?> zzVar) {
        boolean z = true;
        synchronized (this) {
            zm request = zzVar.getRequest();
            if (request != null) {
                if (this.ॱॱ.ˋ(request)) {
                    this.ʼ.ˎ(zzVar);
                    zzVar.setRequest(null);
                } else {
                    z = false;
                }
            }
        }
        return z;
    }

    synchronized void ˏ(@NonNull zz<?> zzVar, @NonNull zm zmVar) {
        this.ʼ.ˋ(zzVar);
        this.ॱॱ.ॱ(zmVar);
    }

    List<zn<Object>> ʽ() {
        return this.ˏॱ;
    }

    synchronized zp ʻ() {
        return this.ͺ;
    }

    @NonNull
    <T> rq<?, T> ˏ(Class<T> cls) {
        return this.ˋ.ॱ().ˏ(cls);
    }

    public synchronized String toString() {
        return super.toString() + "{tracker=" + this.ॱॱ + ", treeNode=" + this.ᐝ + "}";
    }

    public void onTrimMemory(int i) {
        if (i == 60 && this.ˊॱ) {
            ˎ();
        }
    }

    public void onLowMemory() {
    }

    public void onConfigurationChanged(Configuration configuration) {
    }
}
